<?php
/**
 * Created by JetBrains PhpStorm.
 * User: Đặng Khánh Trung
 * Date: 11/6/12
 * Time: 10:51 PM
 * To change this template use File | Settings | File Templates.
 */
defined('_JEXEC') or die;

class VastViewCauhinhs extends JViewLegacy
{
    protected $items;
    protected $pagination;
    protected $state;
    protected $canDo;

    /**
     * Display the view
     *
     * @return    void
     */
    public function display($tpl = null)
    {
        $this->form		= $this->get('Form');        
        $this->items = $this->get('Items');
        $this->pagination = $this->get('Pagination');
        $this->state = $this->get('State');

        JLoader::register('CauhinhsHelper', JPATH_COMPONENT . '/helpers/cauhinh.php');
        $this->canDo = CauhinhsHelper::getActions();

        // Check for errors.
        if (count($errors = $this->get('Errors'))) {
            JError::raiseError(500, implode("\n", $errors));
            return false;
        }

        $this->addToolbar();

        parent::display($tpl);
    }

    /**
     * Add the page title and toolbar.
     *
     * @since    1.6
     */
    protected function addToolbar()
    {
        JToolBarHelper::title(JText::_('COM_VAST_MANAGER_CAUHINHS'), 'head vm_manufacturer_48');

        if ($this->canDo->get('vast.cauhinh.manage')) {        
            JToolBarHelper::custom('cauhinhs.customEdit', 'edit', 'edit', 'COM_VAST_CAUHINH_JTOOLBAR_EDIT', false);
            JToolBarHelper::divider();
        }

        if ($this->canDo->get('core.admin')) {
            JToolBarHelper::preferences('com_vast', '550', '875', 'COM_VAST_JTOOLBAR_OPTIONS');
            JToolBarHelper::divider();
        }

        JToolBarHelper::help('', '', JText::_('COM_VAST_HELP_LINK'));
        
    }
}